<?php
namespace DaChongQing\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        echo "你访问的是大重庆";
    }

    public function SendBonus(){
        $openid = I('openid');
        $bonus = I('bonus');
        $pay = new BonusController($openid,$bonus);
        $md5sign = $pay->SetSign();
        $parameters = array(
            'nonce_str' => '123123131231321',
            'sign' => $md5sign,
            'mch_billno' => $pay->wxMchBillno('1252370801'),
            'mch_id' => '1252370801',
            'wxappid' => 'wx22c589512a2d5f61',
            'nick_name' => '我爱大重庆',
            'send_name' => '我爱大重庆',
            're_openid' => $openid,
            'total_amount' => $bonus,
            'min_value' => $bonus,
            'max_value' => $bonus,
            'total_num' => '1',
            'wishing' => '恭喜发财！',
            'client_ip' => '121.40.30.107',
            'act_name' => '恭喜发财',
            'remark' => '恭喜发财'
        );
        $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack';
        $info = $pay->wxHttpsRequestPem($url,$pay->wxArrayToXml($parameters));
        M('user_gold')->where(array('openid'=>$openid))->setDec('gold','3');
        $this->ajaxReturn($info,'EVAL');
    }
}
